package com.unionpay.upyzt.spring.example.entity;


import com.unionpay.upyzt.Upyzt;
import com.unionpay.upyzt.exception.InvalidRequestException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SettleAcct {
    private String bankCode;
    private String name;
    private String bankAddressCode;
    private String bankBranchCode;
    private String bankAcctNo;

    public Map<String,Object> toMap(){
        Map<String, Object> settleAcct = new HashMap<>();
        settleAcct.put("bank_code", this.bankCode);
        try {
            settleAcct.put("name", Upyzt.encryptField(this.name));
            settleAcct.put("bank_acct_no", Upyzt.encryptField(this.bankAcctNo));
        } catch (InvalidRequestException e) {
            throw new RuntimeException(e);
        }
        settleAcct.put("bank_address_code",this.bankAddressCode);
        settleAcct.put("bank_branch_code", this.bankBranchCode);

        return settleAcct;
    }
}
